package io.renren.sf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import io.renren.sf.dao.CbUnitDao;
import io.renren.sf.entity.CbUnitEntity;
import io.renren.sf.service.CbUnitService;


@Service("cbUnitService")
public class CbUnitServiceImpl extends ServiceImpl<CbUnitDao, CbUnitEntity> implements CbUnitService {

    @Override
    public Page<CbUnitEntity> getUnitByBookId(Map<String, Object> params) {
        String contentsId = (String) params.get("contentsId");
        long page = Long.parseLong((String) params.get("page"));
        long limit = Long.parseLong((String) params.get("limit"));
        Page<CbUnitEntity> unitPage = new Page<>(page, limit);
        baseMapper.selectPage(unitPage, new QueryWrapper<CbUnitEntity>().eq("cid", contentsId));
        return unitPage;
    }
}